﻿using System;
using RpcHelper;
using RpcModel;
using SqlExecHelper;
using SqlExecHelper.SetColumn;
using Wedonek.RpcStore.Service.Helper;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.DAL
{
    internal class ResourceModularDAL : SqlBasicClass
    {
        public ResourceModularDAL() : base("ResourceModular", "RpcExtendService")
        {

        }
        public void SetRemark(Guid id, string remark)
        {
            if (!base.Update(new ISqlSetColumn[] {
                                new SqlSetColumn("Remark", System.Data.SqlDbType.NVarChar,50){ Value=remark}
                        }, "Id", id))
            {
                throw new ErrorException("rpc.resource.modular.set.fail");
            }
        }

        internal ResourceModular Get(Guid modularId)
        {
            return base.GetRow<Guid, ResourceModular>("Id", modularId);
        }

        public BasicModular[] Gets(long systemTypeId)
        {
            return base.Get<long, BasicModular>("SystemTypeId", systemTypeId);
        }
        public ResourceModular[] Query(ModularQueryParam query, IBasicPage paging, out long count)
        {
            paging.InitOrderBy("Id", true);
            return base.Query<ResourceModular>(paging.OrderBy, paging.Index, paging.Size, out count, query.ToWhere());
        }
    }
}
